package com.ebs.md.api.hit;

/**
 * Perforce Revision:
 *  $File: //depot/MarketData/commons-md-api/MAIN/src/main/java/com/ebs/md/api/OrderSide.java $
 *  $Revision: #2 $  $Change: 114786 $  $DateTime: 2012/09/10 08:47:19 $  $Author: Arik.Sher $
 */

import com.ebs.md.api.BookSide;
import com.ebs.md.api.OrderSide;


public enum HitSide
{
	 SELL (0, OrderSide.BID)
	,BUY  (1, OrderSide.OFFER)
	;
	/**
	 * @see com.ebs.core.Core#CODE_HitType_BUY
	 * @see com.ebs.core.Core#CODE_HitType_BUY
	 */
	 
	private int legacyCode;
	private OrderSide matchOrderSide;
	
	private HitSide(int legacyCode, OrderSide matchOrderSide) {
		this.legacyCode = legacyCode;
		this.matchOrderSide = matchOrderSide;
	}

	public int getLegacyCode() {
		return legacyCode;
	}
	
	public OrderSide getMatchOrderSide() {
		return matchOrderSide;
	}

	public BookSide getMatchBookSide() {
		return matchOrderSide.getMatchBookSide();
	}
	
	public HitSide getOtherSide() {
		if ( this.equals(SELL) ) {
			return BUY;
		}
		if ( this.equals(BUY) ) {
			return SELL;
		}
		return null;
	}
	
	public static HitSide byLegcayCode(int legacyCode) {
		if ( SELL.legacyCode == legacyCode ) {
			return SELL;
		}
		if ( BUY.legacyCode == legacyCode ) {
			return BUY;
		}
		return null;
	}
	
}
